<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>新增重点防控病患</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css" th:href="@{/static/layui/css/layui.css}">

</head>

<body style="width: 800px;height: 600px;">
<!--编辑表单-->
<div id="editBook">
    <form class="layui-form" id="saveBook" style="margin-top:10px">
        <input type="hidden" name="id" id="id">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">楼层编号(楼号+层号)</label>
                <div class="layui-input-inline">
                    <input type="text" name="floorSite" id="floorSite" required lay-verify="required" autocomplete="off"
                           class="layui-input" placeholder="必填">
                </div>
            </div>
        </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">楼层长姓名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" id="name" required lay-verify="required" autocomplete="off"
                               class="layui-input" placeholder="必填">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">学号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="studentNumber" id="studentNumber" required lay-verify="required" autocomplete="off"
                               class="layui-input" placeholder="必填">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">联系方式</label>
                    <div class="layui-input-inline">
                        <input type="text" name="phone" id="phone" required lay-verify="required" autocomplete="off"
                               class="layui-input" placeholder="必填">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">当日该层所需药品供应状态</label>
                    <div class="layui-input-inline">
                        <select name ="ispost" lay-filter="levelM" required>
                            <option value ="1" checked="checked">已配送</option>
                            <option value ="2" >未配送</option>
                        </select>
                    </div>
                </div>
            </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">初始化楼层长登陆密码(默认123456)</label>
                <div class="layui-input-inline">
                    <input type="text" name="password" id="password" required lay-verify="required" autocomplete="off"
                           class="layui-input" placeholder="必填" value="123456">
                </div>
            </div>
        </div>

        <div class="layui-form-item" style="margin-top:40px" id="check">
            <div class="layui-input-block">
                <button class="layui-btn  layui-btn-submit " lay-submit="" lay-filter="saveBook">保存</button>
                <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
            </div>
        </div>
    </form>
</div>


<script src="/static/js/jquery-1.11.3.min.js" th:src="@{/static/js/jquery-1.11.3.min.js}"></script>
<script src="/static/layui/layui.all.js" th:src="@{static/layui/layui.all.js}"></script>
<script src="/static/js/util.js" th:src="@{/static/js/util.js}"></script>

<!--ctx-->
<script th:replace="~{fragment::ctx}"/>

<script>
    var element, layer, laydate, form;

    $(function () {

        // 使用模块
        layui.use(['element', 'layer', 'laydate', 'form'], function () {
            element = layui.element;
            layer = layui.layer;
            laydate = layui.laydate;
            form = layui.form;
        });

        form.verify({
            integer:[
                /^[0-9]\d*$/
                ,'只能输入整数！'
            ]
        });


        //监听表单提交
        // 修改
        form.on('submit(saveBook)', function (data) {
            //layer.alert(JSON.stringify(data.field));
            $.ajax({
                url: ctx+'api/floorAdmin/save',
                type: 'POST',
                contentType: "application/json",
                dataType: "json",
                data: JSON.stringify(data.field),
                success: function (result) {
                    if (result.code == 200) {
                        // layer.msg("修改成功！", {icon: 6});
                        cleanForm("#saveBook");
                        layer.closeAll();//关闭所有的弹出层
                        top.$(".layui-show").find("iframe")[0].contentWindow.userTable.reload();
                    } else {
                        layer.alert(result.message);
                    }
                }
            });

            return false;

        });
    });


</script>
</body>

</html>